/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bu;

import java.sql.*;
/**
 *
 * @author stefano
 */
public class DBManager {
    
    public void accessDB() {
        String url = "jdbc:derby://localhost:1527/sample";
        String user = "app";
        String pwd = "app";
        try {
            DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection c = DriverManager.getConnection(url, user, pwd);
            Statement st = c.createStatement();
            ResultSet rs = st.executeQuery("SELECT * FROM CUSTOMER");

            while (rs.next()) {
                System.out.println("NAME =" + rs.getString("NAME") + ", CITY = " + rs.getString("CITY"));
            }
            
            rs.close();
            st.close();
            c.close();
        } catch(SQLException e) {
            System.out.println(e.getMessage());
        }
    }
}
